﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OutdoorLib.BaseEntity.Infrastructure;
using Grishko.DataTier;
using Grishko.SerilizeTools;
using OutdoorLib.BaseEntity.Constraction;
using System.Data;

namespace OutdoorLib.BaseEntity.Agency 
{

    public class Group : SqlAgencyEntity
    {
        public enum EGroupType { SurfaceGroup, ClientGroup }
        public virtual Filter SelectFilter { get; set; }
        public virtual EntityList Items { get; set; }
        public virtual EGroupType GroupType { get; set; }
        public virtual string Describe{ get; set; }
        
        [SrchItemInfo(TxtPropertyName = "Нименование")]        
        public virtual string Name { get; set; }
    }
    [TagNameInfo(TagName = "SurfaceGroup")]
    public class TSurfaceGroup : Group
    {
        public override Group.EGroupType GroupType
        {
            get
            {
                return EGroupType .SurfaceGroup;
            }
            set { ;}
        }
        public override string Describe{get;set;}

        EntityList _Items = new EntityList();
        [SrchItemInfo(TxtPropertyName = "Стороны", ListType = typeof(Side))]
        public override EntityList Items
        {
            get
            {
                return _Items;
            }
            set
            {
                _Items = value;
            }
        }

    }
    public class TClientGroup : Group
    {
        public override EGroupType GroupType
        {
            get

            {
                return EGroupType.ClientGroup;  
            }
        }
    }

    public class TGroupList:EntityList 
    {
        /// <summary>
        /// Вернуть типы групп в виде: Value = Group.EGroupType.Client, ParamID = "Клиенты" 
        /// </summary>
        public static List<DictionaryItem> GroupTypes
        {
            get
            {
                List<DictionaryItem> r = new List<DictionaryItem>();
                r.Add(new DictionaryItem() { Value = Group.EGroupType.ClientGroup, ParamID = "Клиенты" });
                r.Add(new DictionaryItem() { Value = Group.EGroupType.SurfaceGroup, ParamID = "Поверхности" });
                return r;
            }
        }

        public static OutdoorLib.BaseEntity.Agency.Group.EGroupType CovertStringToGroupType(string value)
        { 
            if(string .CompareOrdinal (value ,Group.EGroupType .ClientGroup.ToString ())==0)
                            return Group.EGroupType .ClientGroup ;

            return Group.EGroupType.SurfaceGroup;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="GroupType"></param>
        /// <returns></returns>
        public static string GetPageKey(Group.EGroupType GroupType )
        {
            switch (GroupType)
            { 
                case Group.EGroupType.SurfaceGroup :
                    return "PageKey_SurfaceGroupEditor";
            }
            return "";

        }

    }
}
